<%
QString lang = httpRequest().cookie("lang");
QString skin = httpRequest().cookie("miniuiSkin");
QString mode = httpRequest().cookie("miniuiMode");

QString currentUserZh = controller()->session().value("currentUserZh").toString();
QString currentUserEn = controller()->session().value("currentUserEn").toString();
QString loginUserName = controller()->identityKeyOfLoginUser();

QString toDoRole = httpRequest().cookie("toDoRole");
int currentRoleId = hmacVal(toDoRole).toInt();
int currentUserId = controller()->session().value("currentUserId").toInt();

TSqlQuery query;
query.prepare("SELECT "\
              "r.role_id, "\
              "r.role_name_zh, "\
              "r.role_name_en "\
              "FROM role_app r "\          
              "LEFT JOIN role_user ru "\        
              "ON ru.role_id = r.role_id "\ 
              "WHERE ru.user_id=:user_id "\
              "ORDER BY r.role_cd");   
query.bind(":user_id",currentUserId);
query.exec();
if (!query.isActive()){
    tDebug("query error:%s",query.lastQuery().toLatin1().data());
}               
%>
<h1 style="margin:5px;width:525px;font-family:Microsoft YaHei,SimHei,SimSun; display:inline"><%== UI("Aircraft Maintenance Management System") %></h1>
	<div style="position: absolute;text-align:right;right:12px;font-size:12px;line-height:25px;font-weight:normal;display:inline-block;">
		<div style="display: inline-block; margin-left:2px"><%== UI("Skin") %>:</div>
		<select id="selectSkin" onchange="onSkinChange(this.value)">
			<option value="">Default</option>
			<option value="blue" <%== skin=="blue"? "selected='selected'":"" %>>Blue</option>
			<option value="pure" <%== skin=="pure"? "selected='selected'":"" %>>Pure</option>
			<option value="gray" <%== skin=="gray"? "selected='selected'":"" %>>Gray</option>                
			<option value="olive2003" <%== skin=="olive2003"? "selected='selected'":"" %>>Olive2003</option>
			<option value="blue2003" <%== skin=="blue2003"? "selected='selected'":"" %>>Blue2003</option>
			<option value="blue2010" <%== skin=="blue2010"? "selected='selected'":"" %>>Blue2010</option>
			<option value="bootstrap" <%== skin=="bootstrap"? "selected='selected'":"" %>>Bootstrap</option>
			<option value="metro" <%== skin=="metro"? "selected='selected'":"" %>>metro</option>
			<option value="metro-green" <%== skin=="metro-green"? "selected='selected'":"" %>>metro-green</option>
			<option value="metro-orange" <%== skin=="metro-orange"? "selected='selected'":"" %>>metro-orange</option>
			<option value="jqueryui-cupertino" <%== skin=="jqueryui-cupertino"? "selected='selected'":"" %>>jqueryui-cupertino</option>
			<option value="jqueryui-smoothness" <%== skin=="jqueryui-smoothness"? "selected='selected'":"" %>>jqueryui-smoothness</option>
		</select>
		<div style="display: inline-block; margin-left:2px"><%== UI("Size") %>:</div>
		<select id="selectMode" onchange="onModeChange(this.value)">
		    <option value="small"<%== mode=="small"? "selected='selected'":"" %>>Small</option> 		
			<option value=""<%== mode==""? "selected='selected'":"" %>>Default</option>				
			<option value="medium"<%== mode=="medium"? "selected='selected'":"" %>>Medium</option>
			<option value="large"<%== mode=="large"? "selected='selected'":"" %>>Large</option>         	
		</select>
		<div style="display: inline-block; margin-left:2px"><%== UI("Language") %>:</div>
		<select id="selectLang" onchange="onLangChange(this.value)">
			<option value="zh" <%== lang=="zh"? "selected='selected'":"" %>>中文</option>
			<option value="en" <%== lang=="en"? "selected='selected'":"" %>>English</option>               
		</select>
		<div style="display:inline-block; margin-left:2px"><%== UI("Current User") %>:<%== lang=="zh"? currentUserZh:currentUserEn %>(<%== loginUserName %>)</div>
		<div style="display:inline-block; margin-left:2px"><%== UI("Roles") %>:</div>
		<select id="selectToDoRole" onchange="onToDoRoleChange(this.value)">
			<option value=""></option>
			 <% while (query.next()) { %>
             <%    QSqlRecord record = query.record(); %>
			 <%    QString hash=hmac(record.value(0).toInt());    %>
			       <option value="<%== hash %>" <%== currentRoleId==record.value(0).toInt()? "selected='selected'":"" %>><%== lang=="zh"? record.value(1):record.value(2) %></option>
			 <% } %>
             <% query.finish(); %>             
		</select>
		<a href="/Welcome/logOut"><%== UI("Quit") %></a>
	</div>